<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
        $sql="select * from `".$oto."_users` where userId='{$user_id}'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_dq_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
        $sql="select * from `".$oto."_users`";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_zhong_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$sql="select * from `".$oto."_users` where partnerId='{$user_id}'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_one_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($user_one_info))
		{
			$data[0]['all']=0;
			$data[0]['one']=0;
			$data[0]['two']=0;
			$data[0]['three']=0;
		}
		else
		{
			$one=0;
			for($i=0;$i<count($user_zhong_info);$i++)
			{
				for($j=0;$j<count($user_one_info);$j++)
				{
					if($user_one_info[$j]['userId']==$user_zhong_info[$i]['partnerId'])
					{
						$user_two_info[$one]=$user_zhong_info[$i];
						$one++;
					} 
				}
			}
			$data[0]['one']=$one;
			if(isset($user_one_info)) $data[0]['one']=count($user_one_info);
			if(!isset($user_two_info))
			{
				$data[0]['two']=0;
				$data[0]['three']=0;
			}
			else
			{
				$two=0;
				for($i=0;$i<count($user_zhong_info);$i++)
				{
					for($j=0;$j<count($user_two_info);$j++)
					{
						if($user_two_info[$j]['userId']==$user_zhong_info[$i]['partnerId'])
						{
							$user_three_info[$one]=$user_zhong_info[$i];
							$two++;
						} 
					}
				}
				$data[0]['two']=$two;
				$data[0]['three']=count($user_three_info);
			}
			$data[0]['all']=count($user_one_info);
			if(isset($user_two_info))
			{
				$data[0]['all']=count($user_one_info)+count($user_two_info);
			}
			if(isset($user_three_info))
			{
				$data[0]['all']=count($user_one_info)+count($user_two_info)+count($user_three_info);
			}
		}
		$data[0]['ljxs']=$user_dq_info[0]['agentTotalPrice'];
		$data[0]['ljyj']=$user_dq_info[0]['agentTotalPrice'];
		$data[0]['my_yj']=$user_dq_info[0]['agentTotalPrice'];
		$data[0]['ytx_yj']=$user_dq_info[0]['agentPayPrice'];
        $data[0]['ktx_yj']=$user_dq_info[0]['agentBalance'];
        $data[0]['dqs_yj']=$user_dq_info[0]['agentWaitPrice'];
        $data[0]['ytx_yj']=$user_dq_info[0]['agentPayPrice'];
		echo json_encode($data);
?>